Skip to content

perf: memoize k×s segment-id construction - #364

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/kxs-cache
Jul 8, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/kxs-cache

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Follow-up to the k×s coupling (#362): the design promised the segment map cached; phase 2 rebuilt it per call — a per-likelihood-evaluation cost in fits. lru_cache on the sizes' bytes: first call 62 ms on a realistic 3000-pixel adaptive mask, cached calls 83 µs (×750), returned array read-only, guard behaviour identical. Suite: 863 passed, zero test edits (behaviour-preserving).

🤖 Generated with Claude Code

The segment ids are static per (grid, s) pair but the partial pre-bin runs
once per likelihood evaluation in a fit, and the per-pixel construction
loop cost ~60 ms on a realistic 3000-pixel adaptive mask — per evaluation.
An lru_cache on the sizes' bytes makes repeat calls ~80 us (x750). The
returned array is marked read-only (shared across callers); the
divisibility guard fires identically through the cache.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 8, 2026
@Jammy2211
Jammy2211 merged commit 4ed7472 into main Jul 8, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/kxs-cache branch August 25, 2026 18:16
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant